package com.javasm.http;


import java.util.HashMap;

/**
 * 响应返回实体类
 */

public class AjaxRespEntity extends HashMap<String,Object> {

    private static final String STATUS="status";
    private static final String MESSAGE="message";
    private static final String DATA="data";




    private AjaxRespEntity(AjaxMsgEnum ajaxMsgEnum) {
        this.put(STATUS,ajaxMsgEnum.getStatus());
        this.put(MESSAGE,ajaxMsgEnum.getMessage());
    }


    //操作失败不携带数据
    public static AjaxRespEntity operateFiled(){
        AjaxRespEntity ajaxRespEntity = new AjaxRespEntity(AjaxMsgEnum.Error);
        return ajaxRespEntity;
    }
    //操作失败携带数据
    public static AjaxRespEntity operateFiled(Object data){
        AjaxRespEntity ajaxRespEntity = new AjaxRespEntity(AjaxMsgEnum.Error);
        ajaxRespEntity.put(DATA,data);
        return ajaxRespEntity;
    }

    //邮箱不存在
    public static AjaxRespEntity emailNotExist(Object data){
        AjaxRespEntity ajaxRespEntity = new AjaxRespEntity(AjaxMsgEnum.Error);
        ajaxRespEntity.put(DATA,data);
        return ajaxRespEntity;
    }



    //操作成功并携带数据
    public static AjaxRespEntity operateSuccess(Object data){
        AjaxRespEntity ajaxRespEntity = new AjaxRespEntity(AjaxMsgEnum.OK);
        ajaxRespEntity.put(DATA,data);
        return ajaxRespEntity;
    }

    //操作成功不携带数据
    public static AjaxRespEntity operateSuccess(){
        AjaxRespEntity ajaxRespEntity = new AjaxRespEntity(AjaxMsgEnum.OK);
        return ajaxRespEntity;
    }


    //自定义返回
    public static AjaxRespEntity selfOperate(AjaxMsgEnum ajaxMsgEnum){
        AjaxRespEntity ajaxRespEntity = new AjaxRespEntity(ajaxMsgEnum);
        return ajaxRespEntity;
    }

}
